

<a href="index.php?module=VoteDataCenter&type=election&func=report">Election Report</a> 
| <a href="index.php?module=VoteDataCenter&type=election&func=edit">Edit Election Report</a> 
| <a href="index.php?module=VoteDataCenter&type=suratreport&func=pollreport">Poll Report </a>
| <a href="index.php?module=VoteDataCenter&type=suratreport&func=mappoll">Edit Poll Report</a> 
| <a href="index.php?module=VoteDataCenter&type=suratreport&func=report">Scanner Report </a>
<br>
<fieldset>
  <legend>&nbsp;Report&nbsp;filter&nbsp;</legend>
  <form method=post action="<!--[pnmodurl modname='VoteDataCenter' type='suratreport' func='report']-->">
    <select name="form[khet_id]" id="form_khet_id_">
        <option value="0">ทุกเขต</option>
        <option value="1" <!--[if $smarty.request.form.khet_id == 1]-->SELECTED<!--[/if]-->>เขต1</option>
        <option value="2" <!--[if $smarty.request.form.khet_id == 2]-->SELECTED<!--[/if]-->>เขต2</option>
        <option value="3" <!--[if $smarty.request.form.khet_id == 3]-->SELECTED<!--[/if]-->>เขต3</option>
        <option value="4" <!--[if $smarty.request.form.khet_id == 4]-->SELECTED<!--[/if]-->>เขต4</option>
    </select>
    <input type="submit" value="submit">
  </form>
</fieldset>

<fieldset>
  <legend>&nbsp;Data&nbsp;</legend>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>
      Google Visualization API Sample
    </title>
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load('visualization', '1', {packages: ['corechart']});
    </script>
    <script type="text/javascript">
      function drawVisualization() {
        // Create and populate the data table.
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'พรรค');
        data.addColumn('number', 'จำนวน');
        data.addRows(2);
  

        data.setValue(0, 0, 'เลือกเรา');
        data.setValue(0, 1, <!--[$sum_count_we]-->);
        data.setValue(1, 0, 'ยังไม่ตัดสินใจ');
        data.setValue(1, 1, <!--[$sum_all_count_unknown]-->);


        <!--[if $smarty.request.form.khet_id]-->
           var text = "ผลการหยั่งเสียงจากแกนเขต "+<!--[$smarty.request.form.khet_id]-->;
        <!--[else]-->
          var text = "ผลการหยั่งเสียงจากแกน "
        <!--[/if]-->

        new google.visualization.PieChart(document.getElementById('visualization')).
        draw(data, {title:text});
      }
      
      google.setOnLoadCallback(drawVisualization);
    </script>
  </head>


  <table>
  <tr>
    <td align="center">
      <div id="visualization" style="width: 800px; height: 400px;">
      </div>
    </td>
  </tr>
  </table>
    

  <table  width="100%" border="0">
    <tr bgcolor="#99CCCC">
      <th width="10%" align="center" rowspan="2">เขต</th>
      <th width="30%" align="center" colspan="2">ผู้มีสิทธิทั้งหมด</th>
      <th width="30%" align="center" colspan="2">เลือกเรา</th>
      <th width="30%" align="center" colspan="2">ยังไม่ตัดสินใจ</th>
    </tr>
    <tr bgcolor="#99CCCC">
      <th width="15%" align="center">จำนวน</th>
      <th width="15%" align="center">%</th>
      <th width="15%" align="center">จำนวน</th>
      <th width="15%" align="center">%</th>
      <th width="15%" align="center">จำนวน</th>
      <th width="15%" align="center">%</th>
    </tr>

       <tr align="right" bgcolor="<!--[cycle values='#FFFFFF,#E8EFF7']-->">
        <td align="center"><!--[$item.name]--></td>
        <td width="15%"><!--[$item.count_all_khet|number_format:0:"":","]--></td>
        <td width="15%">100</td>
        <td width="10%">
          <a href="<!--[pnmodurl modname='VoteDataCenter' type='suratreport' func='person' khet_id=$item.khet_id unit=$item.unit select='we']-->">
          <!--[$item.count_remark_khet|number_format:0:"":","]-->
          </a>
        </td>
          <!--[php]-->
            $item = $this->get_template_vars('item');

            $percent_count_we = number_format(($item['count_remark_khet']*100)/$item['count_all_khet'], 2);

            if($percent_count_we >=91 && $percent_count_we <= 100){
              echo '<td width="10%" bgcolor ="#0099ff" >';
              echo $percent_count_we;
              echo '</td>';
            }else if($percent_count_we >=71 && $percent_count_we < 91){
              echo '<td width="10%" bgcolor ="#33cc00" >';
              echo $percent_count_we;
              echo '</td>';
            }else if($percent_count_we >=51 && $percent_count_we < 71){
              echo '<td width="10%" bgcolor ="#ffffcc" >';
              echo $percent_count_we;
              echo '</td>';
            }else if($percent_count_we >=1 && $percent_count_we < 51){
              echo '<td width="10%" bgcolor ="#ff3300" >';
              echo $percent_count_we;
              echo '</td>';
            }else if($percent_count_we  < 1){
              echo '<td width="10%" bgcolor ="#ffccff" >';
              echo $percent_count_we;
              echo '</td>';
            }
          <!--[/php]-->
        <td width="10%">
          <a href="<!--[pnmodurl modname='VoteDataCenter' type='suratreport' func='person' khet_id=$item.khet_id unit=$item.unit select='unknown']-->">
            <!--[$item.count_unkown_khet|number_format:0:"":","]-->
          </a>
        </td>
        </td>
          <!--[php]-->
            $percent_unknown = number_format(($item['count_unkown_khet']*100)/$item['count_all_khet'], 2);

            if($percent_unknown >=91 && $percent_unknown <= 100){
              echo '<td width="10%" bgcolor ="#0099ff" >';
              echo $percent_unknown;
              echo '</td>';
            }else if($percent_unknown >=71 && $percent_unknown < 91){
              echo '<td width="10%" bgcolor ="#33cc00" >';
              echo $percent_unknown;
              echo '</td>';
            }else if($percent_unknown >=51 && $percent_unknown < 71){
              echo '<td width="10%" bgcolor ="#ffffcc" >';
              echo $percent_unknown;
              echo '</td>';
            }else if($percent_unknown >=1 && $percent_unknown < 51){
              echo '<td width="10%" bgcolor ="#ff3300" >';
              echo $percent_unknown;
              echo '</td>';
            }else if($percent_unknown < 1){
              echo '<td width="10%" bgcolor ="#ffccff" >';
              echo $percent_unknown;
              echo '</td>';
            }
          <!--[/php]-->
      </tr>

     <!--[/foreach]-->
      <!--[php]-->
        $sum_count_all = $this->get_template_vars('sum_count_all');
        $sum_count_we = $this->get_template_vars('sum_count_we');
        $sum_percent_we = number_format(($sum_count_we*100)/$sum_count_all, 2);

        $sum_count_they = $this->get_template_vars('sum_count_they');
        $sum_percent_they = number_format(($sum_count_they*100)/$sum_count_all, 2);

        $sum_count_none_canvasser = $this->get_template_vars('sum_count_none_canvasser');
        $sum_none_canvasser = number_format(($sum_count_none_canvasser*100)/$sum_count_all, 2);

        $sum_count_unknown = $this->get_template_vars('sum_count_unknown');
        $sum_percent_unknown = number_format((($sum_count_unknown*100)/$sum_count_all), 2, ".", ",");


        $sum_all_count_unknown = $this->get_template_vars('sum_all_count_unknown');
        $sum_percent_all_count_unknown = number_format((($sum_all_count_unknown*100)/$sum_count_all), 2, ".", ",");



      <!--[/php]-->
      <tr align="right" bgcolor="<!--[cycle values='#FFFFFF,#E8EFF7']-->">
        <th align="center"><b>รวม</b></td>
        <th><!--[$sum_count_all|number_format:0:"":","]--></th>
        <th>100</th>
        <th><!--[$sum_count_we|number_format:0:"":","]--></th>
          <!--[php]-->
            if($sum_percent_we >=91 && $sum_percent_we <= 100){
              echo '<th width="10%" bgcolor ="#0099ff" >';
              echo $sum_percent_we;
              echo '</th>';
            }else if($sum_percent_we >=71 && $sum_percent_we < 91){
              echo '<th width="10%" bgcolor ="#33cc00" >';
              echo $sum_percent_we;
              echo '</th>';
            }else if($sum_percent_we >=51 && $sum_percent_we < 71){
              echo '<th width="10%" bgcolor ="#ffffcc" >';
              echo $sum_percent_we;
              echo '</th>';
            }else if($sum_percent_we >=1 && $sum_percent_we < 51){
              echo '<th width="10%" bgcolor ="#ff3300" >';
              echo $sum_percent_we;
              echo '</th>';
            }else if($sum_percent_we < 1){
              echo '<th width="10%" bgcolor ="#ffccff" >';
              echo $sum_percent_we;
              echo '</th>';
            }
          <!--[/php]-->
        <th><!--[$sum_all_count_unknown|number_format:0:"":","]--></th>
          <!--[php]-->
            if($sum_percent_all_count_unknown >=91 && $sum_percent_all_count_unknown <= 100){
              echo '<th width="10%" bgcolor ="#0099ff" >';
              echo $sum_percent_all_count_unknown;
              echo '</th>';
            }else if($sum_percent_all_count_unknown >=71 && $sum_percent_all_count_unknown < 91){
              echo '<th width="10%" bgcolor ="#33cc00" >';
              echo $sum_percent_all_count_unknown;
              echo '</th>';
            }else if($sum_percent_all_count_unknown >=51 && $sum_percent_all_count_unknown < 71){
              echo '<th width="10%" bgcolor ="#ffffcc" >';
              echo $sum_percent_all_count_unknown;
              echo '</th>';
            }else if($sum_percent_all_count_unknown >=1 && $sum_percent_all_count_unknown < 51){
              echo '<th width="10%" bgcolor ="#ff3300" >';
              echo $sum_percent_all_count_unknown;
              echo '</th>';
            }else if($sum_percent_all_count_unknown < 1){
              echo '<th width="10%" bgcolor ="#ffccff" >';
              echo $sum_percent_all_count_unknown;
              echo '</th>';
            }
          <!--[/php]-->
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td></td>
        <td></td>
        <td></td>
        <td colspan="2">
          <table width="100%">
            <tr>
              <td bgcolor="#0099ff" width="5%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
              <td width="95%">&nbsp;ระดับคะแนน (91% - 100%)</td> 
            </tr>
          </table>
        </td>
        <td colspan="2">
          <table width="100%">
            <tr>
              <td bgcolor="#ff3300" width="5%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
              <td width="95%">&nbsp;ระดับคะแนน (1% - 50%)</td> 
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td></td>
        <td></td>
        <td></td>
        <td colspan="2">
          <table width="100%">
            <tr>
              <td bgcolor="#33cc00" width="5%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
              <td width="95%">&nbsp;ระดับคะแนน (71% - 90%)</td> 
            </tr>
          </table>
        </td>
        <td colspan="2">
          <table width="100%">
            <tr>
              <td bgcolor="#ffccff" width="5%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
              <td width="95%">&nbsp;ระดับคะแนน (0%)</td> 
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td></td>
        <td></td>
        <td></td>
        <td colspan="2">
          <table width="100%">
            <tr>
              <td bgcolor="#ffffcc" width="5%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
              <td width="95%">&nbsp;ระดับคะแนน (51% - 70%)</td> 
            </tr>
          </table>
        </td>
        <td colspan="2">
          &nbsp;
        </td>
      </tr>
    </table>
<br>


</fieldset>
  </body>
</html>